<template>
  <div class="paddingTop search_page">
    <head-top head-title="动态详情" goBack="true"></head-top>

    <!-- 帖子详情 -->
    <hgroup class="shop_right" style="border-bottom:2px solid gray;margin-top:2rem;height:12rem">
      <h5
        class="shop_title ellipsis"
        style="margin-left:0.4rem;margin-top:-0.8rem"
      >{{dynamics.createPerson}}</h5>

      <header class="shop_detail_header" style="margin-left:1rem;margin-top:0.5rem">
        <!-- <router-link :to="'/dynamicDetail/'+item.id"> -->
        <h4 class="shop_title ellipsis">{{dynamics.title}}</h4>

        <!-- </router-link> -->
      </header>
      <span
        class="shop_title ellipsis"
        style="font-size:0.7rem;margin-left:1.5rem"
      >{{dynamics.content}}</span>
      <h5 class="rating_order_num" style>
        <section class="rating_order_num_left" style="margin-top:0.5rem;margin-left:1.5rem">
          <section class="rating_section">
            <img :src="dynamics.images" style="margin-left:1rem;height:5rem" />
          </section>
          <!-- <section class="order_section">:{{item.content}}</section> -->
        </section>
        <section class="rating_order_num_right"></section>
      </h5>
      <h5 class="fee_distance">
        <p class="distance_time" style="margin-top:1rem">
          <span
            class="order_time"
            style="font-size:0.6rem;margin-left:0.8rem;color:gray"
          >{{dynamics.createTime}}</span>
          <!-- <button style="font-size:0.7rem;background-color:;margin-left:1rem;margin-top:0.2rem">
            <button @click="likenunadd(id,likenum)">❤</button>
            {{dynamics.likenum}}
          </button>-->
          <span style="float:right;margin-right:0.5rem;font-size:0.6rem;color:gray">
            <!-- <svg
              t="1599103639818"
              class="icon"
              viewBox="0 0 1035 1024"
              version="1.1"
              xmlns="http://www.w3.org/2000/svg"
              p-id="2751"
              width="0.7rem"
              height="0.7rem"
            >
              <path
                d="M905.898667 44.032 129.365333 44.032c-71.338667 0-129.365333 58.026667-129.365333 129.365333l0 518.144c0 71.338667 58.026667 129.365333 129.365333 129.365333l253.952 0 134.144 163.84 133.802667-163.84 254.293333 0c71.338667 0 129.365333-58.026667 129.365333-129.365333L1034.922667 173.397333C1035.264 102.058667 977.237333 44.032 905.898667 44.032L905.898667 44.032 905.898667 44.032zM236.885333 498.005333c-34.474667 0-62.464-27.989333-62.464-62.464 0-34.474667 27.989333-62.464 62.464-62.464 34.474667 0 62.464 27.989333 62.464 62.464C299.349333 470.016 271.36 498.005333 236.885333 498.005333L236.885333 498.005333 236.885333 498.005333zM518.144 498.005333c-34.474667 0-62.464-27.989333-62.464-62.464 0-34.474667 27.989333-62.464 62.464-62.464 34.474667 0 62.464 27.989333 62.464 62.464C580.608 470.016 552.618667 498.005333 518.144 498.005333L518.144 498.005333zM799.402667 498.005333c-34.474667 0-62.464-27.989333-62.464-62.464 0-34.474667 27.989333-62.464 62.464-62.464 34.474667 0 62.464 27.989333 62.464 62.464C861.866667 470.016 833.877333 498.005333 799.402667 498.005333L799.402667 498.005333zM799.402667 498.005333"
                p-id="2752"
              />
            </svg>-->
            评论数 {{dynamics.commentnum}}
          </span>
        </p>
      </h5>
    </hgroup>

    <!--评论区 -->
    <div class="pl" v-for="item in commentList" :key="item.id" style>
      <li></li>
      <h5
        class="shop_title ellipsis"
        style="margin-left:0.4rem;margin-top:-1.2rem"
      >{{item.createPerson}}</h5>

      <span style="font-size:0.7rem;margin-left:1.7rem">{{item.context}}</span>
      <br />
      <span
        class="order_time"
        style="font-size:0.6rem;margin-left:0.8rem;color:gray;margin-top:1rem"
      >{{item.createTime}}</span>
      <br />
    </div>
    <!-- <router-link :to="'/commentAdd/'+dynamics.id"> -->
      <button>
        <img
          class="add"
          :src="image"
          style="float:right;position: fixed;bottom: 3.5rem;right: 2.2rem;z-index: 9999;width:3rem;height:3rem"
          @click="commentAdd(dynamics)"
        />
      </button>
    <!-- </router-link> -->
   
  </div>
</template>

<script>
import headTop from "../../components/header/head";
import footGuide from "../../components/footer/footGuide";
import { searchRestaurant } from "../../service/getData";
import { imgBaseUrl } from "../../config/env";
import { getStore, setStore } from "../../config/mUtils";
export default {
  data() {
    return {
      image: require("src/images/12.png"),
      dynamics: "",

      commentList: [],
    };
  },
  methods:{
    commentAdd(dynamics){
       this.$router.push({
         path:"/commentAdd",
         query:{
           id:dynamics.id
         }
       });

    }

  },
  created() {
    
    var vm = this;
    //获取到从列表页传递过来的id值
    var id = this.$route.params.id;
    var did = this.$route.params.id;
    this.axios({
      method: "GET",
      url: `http://172.16.9.12:8081/house/dynamic/selectDynamicById/${id}`,
      params: vm.dynamics,
    }).then(function (res) {
      console.log(res);
      vm.dynamics = res.data.data.dynamics;
    });

    this.axios({
      method: "GET",
      url: `http://172.16.9.12:8081/house/comment/selectCommentById/${did}`,
      params: vm.commentList,
    }).then(function (res) {
      vm.commentList = res.data.data.commentList;
    });
  },
  components: {
    headTop,
  },
};
</script>

<style>
.pl {
  margin-top: 2rem;
  height: 4rem;
  border-bottom: 2px solid lightgray;
}
</style>